/*
LANG:C++
TASK:fence9
ID:luongho3
*/
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fence9.in");
ofstream fout("fence9.out");
struct Point {
       int x;
       int y;     
};
int n,m,p;
int gcd(int n, int m) {
    if (m==0) return n;
    else return gcd(m,n%m);
}
int absv(int n) {
    if (n<0) return -n;
    else return n;
}
int countOnSegment(Point A, Point B) {
    int result = 0;
    int vx,vy,g;
    vx = absv(A.x - B.x);
    vy = absv(A.y - B.y);
    g = gcd(vx,vy);
    vx = (A.x - B.x)/g;
    vy = (A.y - B.y)/g;
    while (B.x != A.x || B.y != A.y) {
          B.x += vx;
          B.y += vy;
          ++result;
    }
    return result-1;
}
int countInRect(Point ll, Point ur) {
    int result = 0;
    result = (ur.x - ll.x - 1) * (ur.y - ll.y - 1);    
    return result;
}
Point O,A,B,C,D;
int oa, ab, oac, acb, ac;
int main() {
    fin >> n >> m >> p;
    O.x = O.y = 0;
    A.x = n;
    A.y = m;
    B.x = p;
    B.y = 0;
    C.x = n;
    C.y = 0;
    D.x = p;
    D.y = m;
    oa = countOnSegment(A,O);
    ab = countOnSegment(A,B);
    ac = countOnSegment(A,C);
    oac = (countInRect(O,A) - oa) / 2;
    //acb = (countInRect(C,D) - ab) / 2;
    if (p>n) {
       acb = (countInRect(C,D) - ab) / 2;
       fout << oac + acb + ac << "\n";
    }
    else if (p==n) {
         fout << oac << "\n";
    }
    else {
         acb = (countInRect(B,A) - ab) / 2;
         fout << oac - acb - ab << "\n";
    }
    return 0;
}
